package ac.svn.accesscontrol.ui.window;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Toolkit;

import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
import javax.swing.JTextPane;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.border.EtchedBorder;
import javax.swing.border.TitledBorder;

public class PasswordUtilityDailog extends JDialog {

    /**
     * Class versioning
     */
    private static final long serialVersionUID = 1L;
    private JTextField userNameTxt;
    private JTextField passwordTxt;
    private JLabel cmdLabel;
    private JTextField pwdFilePathTxt;
    private JTextField utilityPathTxt;
    private JButton browserAuthFileBtn;
    private JButton browserUtilityFileBtn;
    private JButton createUserBtn;
    private JTextPane textPaneProgress;

    public PasswordUtilityDailog() 
    {
    	getContentPane().setBackground(Color.WHITE);
    	setSize(new Dimension(600, 500));
    	setModal(true);
    	setTitle("Password Utility");
    	
    	JLabel lblUserId = new JLabel("User ID");
    	
    	JLabel lblPassword = new JLabel("Password");
    	
    	userNameTxt = new JTextField();
    	userNameTxt.setColumns(10);
    	
    	passwordTxt = new JTextField();
    	passwordTxt.setColumns(10);
    	
    	cmdLabel = new JLabel("");
    	cmdLabel.setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.RAISED, null, null), "Commmad Line", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 70, 213)));
    	
    	JScrollPane scrollPane = new JScrollPane();
    	scrollPane.setBackground(Color.WHITE);
    	scrollPane.setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.RAISED, null, null), "Progress", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 70, 213)));
    	
    	JLabel lblPasswordFile = new JLabel("Password File");
    	
    	pwdFilePathTxt = new JTextField();
    	pwdFilePathTxt.setColumns(10);
    	
    	browserAuthFileBtn = new JButton("Browse..");
    	
    	JLabel lblUtility = new JLabel("Utility");
    	
    	utilityPathTxt = new JTextField();
    	utilityPathTxt.setColumns(10);
    	
    	browserUtilityFileBtn = new JButton("Browse..");
    	
    	createUserBtn = new JButton("Create User");
    	GroupLayout groupLayout = new GroupLayout(getContentPane());
    	groupLayout.setHorizontalGroup(
    		groupLayout.createParallelGroup(Alignment.LEADING)
    			.addGroup(groupLayout.createSequentialGroup()
    				.addContainerGap()
    				.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
    					.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
    						.addGroup(groupLayout.createSequentialGroup()
    							.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
    								.addGroup(groupLayout.createParallelGroup(Alignment.LEADING, false)
    									.addComponent(lblUserId, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
    									.addComponent(lblPassword, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
    								.addComponent(lblPasswordFile))
    							.addGap(14)
    							.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
    								.addComponent(userNameTxt, GroupLayout.DEFAULT_SIZE, 459, Short.MAX_VALUE)
    								.addComponent(passwordTxt, GroupLayout.DEFAULT_SIZE, 459, Short.MAX_VALUE)
    								.addGroup(Alignment.TRAILING, groupLayout.createSequentialGroup()
    									.addGroup(groupLayout.createParallelGroup(Alignment.TRAILING)
    										.addComponent(utilityPathTxt, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 378, Short.MAX_VALUE)
    										.addComponent(pwdFilePathTxt, GroupLayout.DEFAULT_SIZE, 378, Short.MAX_VALUE))
    									.addPreferredGap(ComponentPlacement.RELATED)
    									.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
    										.addComponent(browserAuthFileBtn)
    										.addComponent(browserUtilityFileBtn))))
    							.addGap(18))
    						.addGroup(groupLayout.createSequentialGroup()
    							.addComponent(lblUtility)
    							.addContainerGap(529, Short.MAX_VALUE))
    						.addGroup(Alignment.TRAILING, groupLayout.createSequentialGroup()
    							.addGroup(groupLayout.createParallelGroup(Alignment.TRAILING)
    								.addComponent(scrollPane, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 546, Short.MAX_VALUE)
    								.addComponent(cmdLabel, GroupLayout.DEFAULT_SIZE, 546, Short.MAX_VALUE))
    							.addContainerGap()))
    					.addGroup(Alignment.TRAILING, groupLayout.createSequentialGroup()
    						.addComponent(createUserBtn)
    						.addContainerGap())))
    	);
    	groupLayout.setVerticalGroup(
    		groupLayout.createParallelGroup(Alignment.LEADING)
    			.addGroup(groupLayout.createSequentialGroup()
    				.addContainerGap()
    				.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE)
    					.addComponent(lblUserId)
    					.addComponent(userNameTxt, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
    				.addPreferredGap(ComponentPlacement.RELATED)
    				.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE)
    					.addComponent(lblPassword)
    					.addComponent(passwordTxt, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
    				.addPreferredGap(ComponentPlacement.RELATED)
    				.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE)
    					.addComponent(pwdFilePathTxt, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
    					.addComponent(browserAuthFileBtn)
    					.addComponent(lblPasswordFile))
    				.addPreferredGap(ComponentPlacement.RELATED)
    				.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE)
    					.addComponent(lblUtility)
    					.addComponent(utilityPathTxt, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
    					.addComponent(browserUtilityFileBtn))
    				.addPreferredGap(ComponentPlacement.RELATED)
    				.addComponent(cmdLabel, GroupLayout.PREFERRED_SIZE, 97, GroupLayout.PREFERRED_SIZE)
    				.addPreferredGap(ComponentPlacement.UNRELATED)
    				.addComponent(scrollPane, GroupLayout.DEFAULT_SIZE, 124, Short.MAX_VALUE)
    				.addPreferredGap(ComponentPlacement.RELATED)
    				.addComponent(createUserBtn)
    				.addGap(10))
    	);
    	
    	textPaneProgress = new JTextPane();
    	textPaneProgress.setEditable(false);
    	scrollPane.setViewportView(textPaneProgress);
    	getContentPane().setLayout(groupLayout);
    	
    	centerOnScreen();
    }

    /**
     * @return the userNameTxt
     */
    public JTextField getUserNameTxt() {
        return userNameTxt;
    }

    /**
     * @return the passwordTxt
     */
    public JTextField getPasswordTxt() {
        return passwordTxt;
    }

    /**
     * @return the cmdLabel
     */
    public JLabel getCmdLabel() {
        return cmdLabel;
    }

    /**
     * @return the pwdFilePathTxt
     */
    public JTextField getPwdFilePathTxt() {
        return pwdFilePathTxt;
    }

    /**
     * @return the utilityPathTxt
     */
    public JTextField getUtilityPathTxt() {
        return utilityPathTxt;
    }

    /**
     * @return the browserAuthFileBtn
     */
    public JButton getBrowserAuthFileBtn() {
        return browserAuthFileBtn;
    }

    /**
     * @return the browserUtilityFileBtn
     */
    public JButton getBrowserUtilityFileBtn() {
        return browserUtilityFileBtn;
    }

    /**
     * @return the createUserBtn
     */
    public JButton getCreateUserBtn() {
        return createUserBtn;
    }

    /**
     * @return the textPaneProgress
     */
    public JTextPane getTextPaneProgress() {
        return textPaneProgress;
    }
    
    private void centerOnScreen()
    {
	Dimension scrSize = Toolkit.getDefaultToolkit().getScreenSize();
	Dimension appSize = getSize();
	
	setLocation((int)(scrSize.getWidth()/2 - appSize.getWidth()/2), (int)(scrSize.getHeight()/2 - appSize.getHeight()/2));
    }
    
    
    
}
